import Vue from 'vue'
import Router from 'vue-router'


const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router);



//一级页面
import Home from './../views/home/Home.vue';
//二级页面
const LiuXueNews = ()=>import('./../views/liuxue_news/LiuXueNews.vue');
const AboutUs = ()=>import('./../views/about_us/AboutUs.vue');
const Search = ()=>import('./../components/search/Search.vue');
const MoreUniversity = ()=>import('./../views/home/components/university_info/MoreUniversity.vue');
const CollegeItemIntru = ()=>import('./../views/home/components/university_info/CollegeItemIntru.vue');
const MajorIntroduce = ()=>import('./../views/home/components/university_info/MajorIntroduce.vue');
const NewsList = ()=>import('./../views/home/components/news_list/NewsList.vue');
const CaseDetail = ()=>import('./../views/home/components/case/CaseDetail.vue');
const newsDetail = ()=>import('./../views/home/components/news_list/newsDetail.vue');
const CaseList = ()=>import('@/views/case/CaseList.vue');

const router =  new Router({
    routes:[
        {path:'/',redirect:'/home'},
        {path:'/home',name:'home',component:Home,meta:{name:"首页"}},
        {path:'/liuxue_news',name:'liuxue_news',component:LiuXueNews,meta:{name:"留学资讯"}},
        {path:'/about_us',name:'about_us',component:AboutUs,meta:{name:"关于我们"}},
        {path:'/search',name:'search',component:Search,meta:{name:"搜索"}},
        {path:'/moreUniversity',name:'moreUniversity',component:MoreUniversity,meta:{name:"学院库"}},
        {path:'/collegeItemIntru',name:'collegeItemIntru',component:CollegeItemIntru,meta:{name:"学院详情"}},
        {path:'/majorIntroduce',name:'majorIntroduce',component:MajorIntroduce,meta:{name:"首页"}},
        {path:'/newsList',name:'newsList',component:NewsList,meta:{name:"首页"}},
        {path:'/caseDetail',name:'caseDetail',component:CaseDetail,meta:{name:"案例列表"}},
        {path:'/newsDetail',name:'caseDetail',component:newsDetail,meta:{name:"案例详情"}},
        {path:'/CaseList',name:'CaseList',component:CaseList,meta:{name:"案例列表"}},
    ]
})


router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
        console.log(to.meta.title )
        document.title = to.meta.title
    }
    next()
  })

  

export default router;